/* The file proptaxrev_tpc.dta was created using data from the State and Local Government Finance, 
via Tax Policy Center. The complete government revenue and expenditures dataset is available in
 the ``wealth" Dropbox folder, under data/govfin. */ 

global user "/Users/sk33"
global datadir "$user/Dropbox/wealth/data"
global repodir "$user/syzzle"

do "$repodir/code/wealth/do/adjust_inflation.do"


***** BUILD *****

use "$datadir/govfin/dta/govfin_tpc.dta", clear

* Keep state and local property tax revenue (could only keep one of them if wanted to)
keep if inlist(govtype,"state", "statelocal")


* Only keep variables of interest
keep grev_own_proptax year statename stateab fips govtype

* Rename 
rename grev_own_proptax proptaxrev
format proptaxrev %15.1fc

* Reshape
replace govtype = "_" + govtype 
reshape wide proptaxrev, i(year statename stateab fips) j(govtype, string)

rename (proptaxrev_state proptaxrev_statelocal )  (proptaxrev proptaxrev_sl)

* Adjust for inflation 
g proptaxrev_14 = proptaxrev
g proptaxrev_sl_14 = proptaxrev_sl

adjust_inflation proptaxrev*14, year(2014)

lab var proptaxrev "property tax rev, state only, 1000s, nominal"
lab var proptaxrev_14 "property tax rev, state only, 1000s of 2014 USD"

lab var proptaxrev_sl "property tax rev, state+local, 1000s, nominal"
lab var proptaxrev_sl_14 "property tax rev, state+local, 1000s of 2014 USD"

lab var year "note missing 2001, 2003 for state and local "

* merge population
rename fips statefips

merge m:1 statefips year using $user/Dropbox/salt/data/pop/pop_state.dta, keepusing(pop) assert(2 3) nogen keep(3)

lab var pop "state population"


order state* year proptaxrev proptaxrev_14 proptaxrev_sl proptaxrev_sl_14  pop

save "$datadir/proptaxrev_tpc.dta", replace

